<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.hongkou.tvstation.news.vo.NewsVO"%>
<%@page import="com.hongkou.tvstation.common.utils.StringUtils"%>
<%@page import="com.hongkou.tvstation.image.vo.ImageVO"%>
<%@ taglib uri="/WEB-INF/hongkou.tld" prefix="page"%>
<%@page import="com.hongkou.tvstation.common.CodeCst"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<link href="fun/style.css" rel="stylesheet" type="text/css" />
  <body>
		<form method="get" name="form1" action="newsManagement.do">
		<table width="100%" border="0" cellspacing="0" cellpadding="4">
  		  <tr>
            <td class="td_heng" onclick="ddd()">筛选&nbsp;<input type="hidden" name="imageId" value="<%=request.getParameter("imageId") %>"/>
  <input type="hidden" name="actionType" /></td>
            <td class="td_heng">&nbsp;</td>
          </tr>
          <tr>
            <td>新闻标题：&nbsp;<input type="text" name="title" value="<%=StringUtils.convertToEmpty(request.getParameter("title")) %>"/></td>
            <td>采编：&nbsp;<input type="text" name="caibian" value="<%=StringUtils.convertToEmpty(request.getParameter("caibian")) %>" /></td>
          </tr>
          <tr>
            <td>审核状态：&nbsp;
            	<select name="newstatus" >
            		<option value="1">等待初审</option>
            		<option value="2">等待二审</option>
            		<option value="3">等待终审</option>
            		<option value="4">完成</option>
            	</select>
			</td>
            <td>新闻类型：&nbsp;<input type="text" name="cate" value="<%=StringUtils.convertToEmpty(request.getParameter("cate")) %>"/></td>
          </tr>
          <tr>
            <td align="center" colspan=2><div align="center"><input type="button" name="submit1" value="查询" onclick="javascript:filterNews();"/>
            <%if(!StringUtils.isNullOrEmpty(request.getParameter("imageId"))) {%>
            <input type="button" name="submit1" value="解除图片关联" onclick="javascript:removeImageRelated();"/>
            <%} %></div></td>
          </tr>
          <tr>
            <td class="td_heng" onclick="ddd()">新闻列表&nbsp;</td>
            <td class="td_heng">&nbsp;</td>
          </tr>
    	  <tr >
            <td colspan="2">
			<table width="100%"  cellspacing="0" cellpadding="4" id="line">
			<tr><th>新闻标题</th><th>采编</th><th>采编日期</th><th>审核状态</th><th>新闻类型</th><th>图片状态</th></tr>
			<%List<NewsVO> newsList = (List<NewsVO>)request.getAttribute("news");
			for(NewsVO news : newsList ){
			List<ImageVO> imageList = news.getImageList();
			pageContext.setAttribute("news", news); %>
               <tr>
                 <td><%if(!StringUtils.isNullOrEmpty(request.getParameter("imageId"))) {%>
                 <a target="_blank" href="imageManagement.do?actionType=relateToNews&newsId=${news.id}&imageId=<%=request.getParameter("imageId") %>">${news.title}</a>
                 <%}else{ %>
                 <a target="_blank" href="newsManagement.do?actionType=displayNews&newsId=${news.id}">${news.title}</a>
                 <%} %></td>
                 
                 <td align="center"><%=Arrays.toString(StringUtils.distinctStringValue(news.getCaibian(),news.getCaibian1(),news.getCaibian2())) %></td>
                 <td align="right">${news.caibianDate}</td>
                 <td align="right">${news.status}</td>
                 <td align="center">${news.cate}</td>
                 <td align="center">
                 <%if(imageList != null && !imageList.isEmpty()){
                 	out.print("Y");
                 }else{
                 	out.print("N");
                 }
                  %>
                 </td>
               </tr>
               <%} %>
             </table></td>
             <td colspan="2">&nbsp;</td>
           </tr>
           <tr>
            <td colspan="2" align="right">
            <%if(StringUtils.isNullOrEmpty(request.getParameter("imageId"))) {%>
            <page:page url="newsManagement.do?1=1" pagesize="${pageVO.pageSize}"
                    totalRecords="${pageVO.totalRecords}" pageNum="${pageVO.pageNum}" />
			<%}else{
			pageContext.setAttribute("imageId",request.getParameter("imageId"));
			 %>
			
			<page:page url="newsManagement.do?actionType=showNews&imageId=${imageId}" pagesize="${pageVO.pageSize}"
                    totalRecords="${pageVO.totalRecords}" pageNum="${pageVO.pageNum}" />
			<%} %>
			</td>
             <td colspan="2">&nbsp;</td>
           </tr>
        </table>
           </form>
  </body>
  <%
    response.setCharacterEncoding("UTF-8");
    request.setCharacterEncoding("UTF-8");
%>
  <script type="text/javascript">
  function showNews(){
  	form1.imageId = form1.imageId.value;
  	form1.actionType.value="showNews";
  	form1.action="newsManagement.do";
  	form1.submit();
  	}
function filterNews(){
	if(form1.imageId.value != ''){
		form1.actionType.value="showNews";
	}
	form1.submit();
}
function removeImageRelated(){
	form1.actionType.value="removeImageRelated";
  	form1.action="imageManagement.do";
  	form1.submit();
}
  </script>
</html>
